diff --git a/README.md b/README.md index 54ad06f..961f183 100644 --- a/README.md +++ b/README.md @@ -388,7 +388,7 @@ You can describe the UI way to add new slaves but better to explain how to do in
-How would you implement an option of a starting a build from a certain stage and not from the beginning?
+How would you implement an option of a starting a build from a certain stage and not from the beginning?
##### Jenkins Dev @@ -601,13 +601,13 @@ Stop the instance, the type of the instance to match the desired RAM and start t
What is AWS WAF? Give an example of how it can used and describe what resources or services you can use it with
- -What AWS VPN is usef for?
+
+What AWS VPN is used for?
- +
What is the difference between Site-to-Site VPN and Client VPN?
- +
True or False? AWS Inspector can perform both network and host assessments
True @@ -1370,7 +1370,7 @@ You can also try closing/terminating the parent process. This will make the zomb
-Can you explain how network process/connection is established and how it's terminated?>
+Can you explain how network process/connection is established and how it's terminated?>
@@ -2385,7 +2385,7 @@ Setting the replicas to 0 will shut down the process. Now start it with `kubectl
-Explain recursion +Explain recursion
@@ -3303,7 +3303,7 @@ a = f()
-Can you implement Linked List in Python?
+Can you implement Linked List in Python?
@@ -4147,7 +4147,7 @@ the pseudo table to retrieve the sum of the prices spent by each customer, then
-Describe in detail how you bring up an instance with an IP you can reach from outside the cloud
+Describe in detail how you bring up an instance with an IP you can reach from outside the cloud
diff --git a/scripts/get_answered_questions.py b/scripts/get_answered_questions.py new file mode 100644 index 0000000..383cff6 --- /dev/null +++ b/scripts/get_answered_questions.py @@ -0,0 +1,59 @@ +""" +Usage: + +$ python scripts/get_answered_questions.py + +Writes the number of answered questions to STDOUT + +""" + + +import pathlib +from sys import stdout + +p = pathlib.Path(__file__).parent.parent.joinpath('README.md') + +with open(p, 'rb') as f: + file_list = [line.rstrip() for line in f.readlines()] + + +def get_question_list(file_list) -> list: + + questions_list = [] + temp = [] + after_summary_tag = False + + for line in file_list: + if line.startswith(b'
'): + temp.append(line) + after_summary_tag = True + + elif after_summary_tag and line != b'' and b'
' not in line: + temp.append(line) + + elif after_summary_tag and b'
' in line: + temp.append(line) + after_summary_tag = False + + questions_list.append(temp) + temp = [] + + return questions_list + + +def get_answered_questions(question_list) -> int: + c = 0 + for q in question_list: + index = 0 + for i in q: + if b'' in i: + index = q.index(i) + if q[index+1: len(q) - 1]: + c += 1 + return c + + +if __name__ == '__main__': + question_list = get_question_list(file_list) + n_answers = get_answered_questions(question_list) + stdout.write(str(n_answers)) diff --git a/tests/syntax_checker.py b/tests/syntax_checker.py new file mode 100644 index 0000000..6c7d30b --- /dev/null +++ b/tests/syntax_checker.py @@ -0,0 +1,112 @@ +""" +Testing suite for https://github.com/bregman-arie/devops-interview-questions written by surister + +Even though both check_details_tag and check_summary_tags are practically the same, due to readability and functionality +it was decided to be split like that. + +Usage: +$ python tests/syntax_checker.py + +""" + +import pathlib + +p = pathlib.Path(__file__).parent.parent.joinpath('README.md') + +with open(p, 'rb') as f: + file_list = [line.rstrip() for line in f.readlines()] + +errors = [] + + +def count_details(file_list): + """ + Counts the total amount of
and
+ + Used for debugging purpose, not meant to be used in actual tests + """ + details_final_count = 0 + details_count = 0 + + for line_number, line in enumerate(file_list): + if b'
' in line: + details_count += 1 + if b'
' in line: + details_final_count += 1 + + return details_count, details_final_count + + +def check_details_tag(file_list): + """ + Check whether the structure: +
+ ... +
+ + Is correctly followed, if not generates an error. + + """ + + after_detail = False + error = False + err_message = '' + for line_number, line in enumerate(file_list): + if b'
' in line and b'
' in line: + pass + else: + if b'
' in line and after_detail: + error = True + if b'
' in line and not after_detail: + err_message = 'Missing opening detail tag' + error = True + + if b'
' in line: + after_detail = True + + if b'
' in line and after_detail: + err_message = 'Missing closing detail tag' + after_detail = False + + if error: + raise Exception(f'{err_message} at line {line_number -1}') + + +def check_summary_tag(file_list): + """ + Check whether the structure: + + ... + + + Is correctly followed, if not generates an error. + + """ + + after_detail = False + error = False + err_message = '' + for line_number, line in enumerate(file_list): + if b'' in line and b'' in line: + pass + else: + if b'' in line and after_detail: + error = True + if b'' in line and not after_detail: + err_message = 'Missing opening detail tag' + error = True + + if b'' in line: + after_detail = True + + if b'' in line and after_detail: + err_message = 'Missing closing detail tag' + after_detail = False + + if error: + raise Exception(f'{err_message} at line {line_number -3}') + + +if __name__ == '__main__': + check_details_tag(file_list) + check_summary_tag(file_list) diff --git a/tests/syntax_checker_unittest.py b/tests/syntax_checker_unittest.py new file mode 100644 index 0000000..0f02809 --- /dev/null +++ b/tests/syntax_checker_unittest.py @@ -0,0 +1,35 @@ +""" +WIP + +Yes, we do write tests for our tests. +""" +import unittest +import pathlib + +from tests import * +from scripts import get_answered_questions + + +def open_test_case_file(n: int): + p = pathlib.Path(rf'D:\PycharmProjects\devops-interview-questions\scripts\tests\testcase{n}.md') + + with open(p, 'rb') as f: + file_list = [line.rstrip() for line in f.readlines()] + return file_list + + +class QuestionCount(unittest.TestCase): + solutions = ( + + ) + + def test_count_case_1(self): + raw_list = open_test_case_file(1) + question_list = get_question_list(raw_list) + answers = get_answered_questions.n_answers(question_list) + + self.assertEqual(len(question_list), 21) + self.assertEqual(answers, 2) + + def test_count_case_2(self): + pass