diff --git a/tests/scripts_get_answered_question_unittest.py b/tests/scripts_get_answered_question_unittest.py new file mode 100644 index 0000000..9cb0f3b --- /dev/null +++ b/tests/scripts_get_answered_question_unittest.py @@ -0,0 +1,31 @@ +import unittest +from pathlib import Path +from typing import List +from scripts.get_answered_questions import get_answered_questions, get_question_list + + +def open_test_case_file(n: int) -> List[bytes]: + tests_path = Path(__file__).parent.joinpath() + + with open(f'{tests_path}/testcases/testcase{n}.md', 'rb') as f: + file_list = [line.rstrip() for line in f.readlines()] + return file_list + + +class QuestionCount(unittest.TestCase): + + def test_case_1(self): + raw_list = open_test_case_file(1) + question_list = get_question_list(raw_list) + answers = get_answered_questions(question_list) + + self.assertEqual(len(question_list), 11) + self.assertEqual(answers, 3) + + def test_case_2(self): + raw_list = open_test_case_file(2) + question_list = get_question_list(raw_list) + answers = get_answered_questions(question_list) + + self.assertEqual(len(question_list), 16) + self.assertEqual(answers, 11) diff --git a/tests/syntax_checker.py b/tests/syntax_checker.py index 6ee9ced..8429fac 100644 --- a/tests/syntax_checker.py +++ b/tests/syntax_checker.py @@ -36,7 +36,7 @@ def count_details(file_list): if b'' in line: details_final_count += 1 - return details_count, details_final_count + return details_count == details_final_count def check_details_tag(file_list): diff --git a/tests/syntax_checker_unittest.py b/tests/syntax_checker_unittest.py index 6cc3cc1..9ce590e 100644 --- a/tests/syntax_checker_unittest.py +++ b/tests/syntax_checker_unittest.py @@ -3,37 +3,42 @@ WIP Yes, we do write tests for our tests. """ -import unittest -# import pathlib - -# from tests import * -# from scripts import get_answered_questions +from pathlib import Path +from typing import List +from unittest import TestCase +from tests import syntax_checker -def open_test_case_file(n: int): - pass - # p = pathlib.Path( - # rf'D:\PycharmProjects\devops-interview-questions\scripts\tests\' + ' - # testcase{n}.md') +def open_test_case_file(n: int) -> List[bytes]: + tests_path = Path(__file__).parent.joinpath() - # with open(p, 'rb') as f: - # file_list = [line.rstrip() for line in f.readlines()] - # return file_list + with open(f'{tests_path}/testcases/testcase{n}.md', 'rb') as f: + file_list = [line.rstrip() for line in f.readlines()] + return file_list -class QuestionCount(unittest.TestCase): - solutions = ( +test_case_1 = open_test_case_file(1) +test_case_2 = open_test_case_file(2) +test_case_3 = open_test_case_file(3) - ) - def test_count_case_1(self): - pass - # raw_list = open_test_case_file(1) - # question_list = get_question_list(raw_list) - # answers = get_answered_questions.n_answers(question_list) +class TestSyntax(TestCase): - # self.assertEqual(len(question_list), 21) - # self.assertEqual(answers, 2) + def test_details_count_case1(self): + self.assertTrue(syntax_checker.count_details(test_case_1)) - def test_count_case_2(self): - pass + def test_details_count_case2(self): + self.assertTrue(syntax_checker.count_details(test_case_2)) + + def test_details_errors_1(self): + syntax_checker.check_details_tag(test_case_1) + self.assertFalse(syntax_checker.errors) + + def test_details_errors_2(self): + syntax_checker.check_details_tag(test_case_2) + self.assertFalse(syntax_checker.errors) + # + # def test_details_error_exist_1(self): + # syntax_checker.check_details_tag(test_case_3) + # print(syntax_checker.errors) + # self.assertEqual(len(syntax_checker.errors), 3) diff --git a/tests/testcases/testcase1.md b/tests/testcases/testcase1.md new file mode 100644 index 0000000..72e6831 --- /dev/null +++ b/tests/testcases/testcase1.md @@ -0,0 +1,67 @@ +
+What is Docker? What are you using it for?
+
+ +
+How containers are different from VMs?
+ +The primary difference between containers and VMs is that containers allow you to virtualize +multiple workloads on the operating system while in the case of VMs the hardware is being virtualized to +run multiple machines each with its own OS. +
+ +
+In which scenarios would you use containers and in which you would prefer to use VMs?
+ +You should choose VMs when: + * you need run an application which requires all the resources and functionalities of an OS + * you need full isolation and security + +You should choose containers when: + * you need a lightweight solution + * Running multiple versions or instances of a single application +
+ +
+Explain Docker architecture
+
+ +
+Describe in detail what happens when you run `docker run hello-world`?
+ +Docker CLI passes your request to Docker daemon. +Docker daemon downloads the image from Docker Hub +Docker daemon creates a new container by using the image it downloaded +Docker daemon redirects output from container to Docker CLI which redirects it to the standard output +
+ +
+How do you run a container?
+
+ +
+What `docker commit` does?. When will you use it?
+
+ +
+How would you transfer data from one container into another?
+
+ +
+What happens to data of the container when a container exists?
+
+ +
+Explain what each of the following commands do: + + * docker run + * docker rm + * docker ps + * docker pull + * docker build + * docker commit
+
+ +
+How do you remove old, non running, containers?
+
diff --git a/tests/testcases/testcase2.md b/tests/testcases/testcase2.md new file mode 100644 index 0000000..ccae90a --- /dev/null +++ b/tests/testcases/testcase2.md @@ -0,0 +1,179 @@ +
+Explain the following code: + +:(){ :|:& };: + +
+
+ +
+Can you give an example to some Bash best practices?
+
+ +
+What is the ternary operator? How do you use it in bash?
+ +A short way of using if/else. An example: + +[[ $a = 1 ]] && b="yes, equal" || b="nope" +
+ +
+What does the following code do and when would you use it? + +diff <(ls /tmp) <(ls /var/tmp) + +
+It is called 'process substitution'. It provides a way to pass the output of a command to another command when using a pipe | is not possible. It can be used when a command does not support STDIN or you need the output of multiple commands. +https://superuser.com/a/1060002/167769 +
+ + +## SQL + + +#### :baby: Beginner + +
+What does SQL stand for?
+ +Structured Query Language + +
+ +
+How is SQL Different from NoSQL
+ +The main difference is that SQL databases are structured (data is stored in the form of +tables with rows and columns - like an excel spreadsheet table) while NoSQL is +unstructured, and the data storage can vary depending on how the NoSQL DB is set up, such +as key-value pair, document-oriented, etc. +
+ +
+What does it mean when a database is ACID compliant?
+ +ACID stands for Atomicity, Consistency, Isolation, Durability. In order to be ACID compliant, the database much meet each of the four criteria + +**Atomicity** - When a change occurs to the database, it should either succeed or fail as a whole. + +For example, if you were to update a table, the update should completely execute. If it only partially executes, the +update is considered failed as a whole, and will not go through - the DB will revert back to it's original +state before the update occurred. It should also be mentioned that Atomicity ensures that each +transaction is completed as it's own stand alone "unit" - if any part fails, the whole statement fails. + +**Consistency** - any change made to the database should bring it from one valid state into the next. + +For example, if you make a change to the DB, it shouldn't corrupt it. Consistency is upheld by checks and constraints that +are pre-defined in the DB. For example, if you tried to change a value from a string to an int when the column +should be of datatype string, a consistent DB would not allow this transaction to go through, and the action would +not be executed + +**Isolation** - this ensures that a database will never be seen "mid-update" - as multiple transactions are running at +the same time, it should still leave the DB in the same state as if the transactions were being run sequentially. + +For example, let's say that 20 other people were making changes to the database at the same time. At the +time you executed your query, 15 of the 20 changes had gone through, but 5 were still in progress. You should +only see the 15 changes that had completed - you wouldn't see the database mid-update as the change goes through. + +**Durability** - Once a change is committed, it will remain committed regardless of what happens +(power failure, system crash, etc.). This means that all completed transactions +must be recorded in non-volatile memory. + +Note that SQL is by nature ACID compliant. Certain NoSQL DB's can be ACID compliant depending on +how they operate, but as a general rule of thumb, NoSQL DB's are not considered ACID compliant +
+ +
+When is it best to use SQL? NoSQL?
+ +SQL - Best used when data integrity is crucial. SQL is typically implemented with many +businesses and areas within the finance field due to it's ACID compliance. + +NoSQL - Great if you need to scale things quickly. NoSQL was designed with web applications +in mind, so it works great if you need to quickly spread the same information around to +multiple servers + +Additionally, since NoSQL does not adhere to the strict table with columns and rows structure +that Relational Databases require, you can store different data types together. +
+ +
+What is a Cartesian Product?
+ +A Cartesian product is when all rows from the first table are joined to all rows in the second +table. This can be done implicitly by not defining a key to join, or explicitly by +calling a CROSS JOIN on two tables, such as below: + +Select * from customers **CROSS JOIN** orders; + +Note that a Cartesian product can also be a bad thing - when performing a join +on two tables in which both do not have unique keys, this could cause the returned information +to be incorrect. +
+ +##### SQL Specific Questions + +For these questions, we will be using the Customers and Orders tables shown below: + +**Customers** + +Customer_ID | Customer_Name | Items_in_cart | Cash_spent_to_Date +------------ | ------------- | ------------- | ------------- +100204 | John Smith | 0 | 20.00 +100205 | Jane Smith | 3 | 40.00 +100206 | Bobby Frank | 1 | 100.20 + +**ORDERS** + +Customer_ID | Order_ID | Item | Price | Date_sold +------------ | ------------- | ------------- | ------------- | ------------- +100206 | A123 | Rubber Ducky | 2.20 | 2019-09-18 +100206 | A123 | Bubble Bath | 8.00 | 2019-09-18 +100206 | Q987 | 80-Pack TP | 90.00 | 2019-09-20 +100205 | Z001 | Cat Food - Tuna Fish | 10.00 | 2019-08-05 +100205 | Z001 | Cat Food - Chicken | 10.00 | 2019-08-05 +100205 | Z001 | Cat Food - Beef | 10.00 | 2019-08-05 +100205 | Z001 | Cat Food - Kitty quesadilla | 10.00 | 2019-08-05 +100204 | X202 | Coffee | 20.00 | 2019-04-29 + +
+How would I select all fields from this table?
+ +Select *
+From Customers; +
+ +
+How many items are in John's cart?
+ +Select Items_in_cart
+From Customers
+Where Customer_Name = "John Smith"; +
+ +
+What is the sum of all the cash spent across all customers?
+ +Select SUM(Cash_spent_to_Date) as SUM_CASH
+From Customers; +
+ +
+Tell me about your last big project/task you worked on
+
+ +
+What was most challenging part in the project you worked on?
+
+ +
+Why do you want to work here?
+
+ +
+How did you hear about us?
+ +Tell them how did you hear about them :D +Relax, there is no wrong or right answer here...I think. +
\ No newline at end of file diff --git a/tests/testcases/testcase3.md b/tests/testcases/testcase3.md new file mode 100644 index 0000000..35f73bf --- /dev/null +++ b/tests/testcases/testcase3.md @@ -0,0 +1,58 @@ + +You have a colleague you don‘t get along with. Tell us some strategies how you create a good work relationship with them anyway.
+ +Bad answer: I don't. +Better answer: Every person has strengths and weaknesses. This is true also for colleagues I don't have good work relationship with and this is what helps me to create good work relationship with them. If I am able to highlight or recognize their strengths I'm able to focus mainly on that when communicating with them. + + +
+What do you love about your work?
+ +You know the best, but some ideas if you find it hard to express yourself: + +* Diversity +* Complexity +* Challenging +* Communication with several different teams +
+ +
+What are your responsibilities in your current position?
+ +You know the best :) +
+ + +Why should we hire you for the role?
+ +You can use and elaborate on one or all of the following: + +* Passion +* Motivation +* Autodidact +* Creativity (be able to support it with some actual examples) + + +## Questions you CAN ask + +A list of questions you as a candidate can ask the interviewer during or after the interview. +These are only a suggestion, use them carefully. Not every interviewer will be able to answer these (or happy to) which should be perhaps a red flag warning for your regarding working in such place but that's really up to you. + +
+What do you like about working here?
+
+ +
+How does the company promote personal growth?
+ + +
+What is the current level of technical debt you are dealing with?
+ +Be careful when asking this question - all companies, regardless of size, have some level of tech debt. +Phrase the question in the light that all companies have the deal with this, but you want to see the current +pain points they are dealing with
+ +This is a great way to figure how managers deal with unplanned work, and how good they are at +setting expectations with projects. +
\ No newline at end of file