Esempio n. 1
0
 def test_ReadFile(self):
     parsedJson = {
         1: [[
             1, 'accusamus beatae ad facilis cum similique qui sunt',
             'https://via.placeholder.com/600/92c952',
             'https://via.placeholder.com/150/92c952'
         ]]
     }
     self.assertEqual(parsedJson, readFile(jsonFileCheck("test1.json")),
                      "ReadFile check")
Esempio n. 2
0
 def testJsonFileCheck(self):
     self.assertEqual([{
         'test': 'passed'
     }], jsonFileCheck("test.json"), ".json file check")
Esempio n. 3
0
 def test_StandardOutput_Object(self, mock_stdout):
     photoAlbums = createObjects(jsonFileCheck("test1.json"))
     photoAlbums[1].displayContents()
     excpectedOut = '\nPhoto Album 1 contains:\n\n[1] accusamus beatae ad facilis cum similique qui sunt\n'
     self.assertEqual(mock_stdout.getvalue(), excpectedOut)
Esempio n. 4
0
 def test_StandardOutput_Non_Object(self, mock_stdout):
     file = readFile(jsonFileCheck("test1.json"))
     printFile(file, 1)
     excpectedOut = '\nPhoto Album 1 contains:\n\n[1] accusamus beatae ad facilis cum similique qui sunt\n'
     self.assertEqual(mock_stdout.getvalue(), excpectedOut)
Esempio n. 5
0
 def test_JsonFile_Repeated_BadInput_Quit(self):
     userInput = ["na", "none", "nothing", "quit"]
     with mock.patch('builtins.input', side_effect=userInput):
         with self.assertRaises(SystemExit) as cm:
             jsonFileCheck("nonsense")
         self.assertEqual(cm.exception.code, 0)
Esempio n. 6
0
 def testJson_File_Repeated_Bad_Input(self):
     userInput = ["na", "none", "nothing", "test.json"]
     with mock.patch('builtins.input', side_effect=userInput):
         answer = jsonFileCheck("nonsense")
     self.assertEqual([{"test": "passed"}], answer)