Пример #1
0
    def __create_table(self, table):
        class Test:
            def __init__(self, name):
                self.name = name

            def __str__(self):
                return 'Test'

        self.user = Test('Petr')
        self.bd = WkBD(MainClass.read_ini())

        self.bd.cursor.execute(f'create table IF NOT EXISTS {table} (id integer PRIMARY KEY, name text);')
        self.bd.cursor.execute(f"insert into {table} (name) values ('Petr')")
        self.bd.commit_session()
Пример #2
0
 def test_bd_not_exists(self):
     sql_file = MainClass.read_ini() + '_not_ex'
     self.assertRaises(FileExistsError, WkBD._check_exists_db, sql_file)
Пример #3
0
 def test_bd_exists(self):
     sql_file = MainClass.read_ini()
     self.assertTrue(WkBD._check_exists_db(sql_file))
Пример #4
0
 def test_read_ini_file(self):
     self.assertIsNotNone(MainClass.read_ini())
Пример #5
0
 def test_incorrect_json_parser(self):
     main_class = MainClass('http://pawka.ru')
     response = main_class._get_json_data()
     self.assertRaises(Exception, main_class._parse_json, response)
Пример #6
0
 def test_json_parser(self):
     main_class = MainClass('http://jsonplaceholder.typicode.com/users')
     response = main_class._get_json_data()
     parsed = main_class._parse_json(response)
     for row in parsed:
         self.assertIs(type(row['id']), int)
Пример #7
0
 def test_incorrect_url(self):
     main_class = MainClass('http://jsonplaceholder.typicode.com/users3')
     response = main_class._get_json_data()
     self.assertEqual(response.status_code, 404)