Beispiel #1
0
    def setUp(self) -> None:
        self.path = os.path.join(parentdir,"ta")
        DirManagement.create_dir(self.path)
        workdata = {
    "workDraft": {
        "outputDraft": ["studentId", 
            "param1", 
            "param2", 
            "comment", 
            "score", 
            "scoreTimestamp"], 
        "fileDraft": "{studentId}_test.zip"
    },
    "scores": [
        {
            "studentId": "6310545000",
            "param1": "100",
            "param2": "print('hello')",
            "comment": "good",
            "score": "10",
            "scoreTimestamp": "100"
        }]
}    
        data = {"prefix" : "https://ta-api.sirateek.dev/",
                "workId" : 'testWork2'}
        with open(os.path.join(self.path, 'config.json'), "w") as wri:
            json.dump(data, wri) 
        with open(os.path.join(self.path, "work.json"), "w") as create:
            json.dump(workdata, create)
        SaveApiKey().removeapikey()
        SaveApiKey().save('testKey')
        self.post = SendData(parentdir)
        return super().setUp()
Beispiel #2
0
 def setUp(self) -> None:
     self.path = os.path.join(parentdir, "ta")
     DirManagement.create_dir(self.path)
     self.data = {
         "prefix": "https://ta-api.sirateek.dev/",
         "workId": 'testWork2'
     }
     with open(os.path.join(self.path, 'config.json'), "w") as wri:
         json.dump(self.data, wri)
     SaveApiKey().removeapikey()
     SaveApiKey().save('testKey')
     self.call = CallApi(parentdir)
     return super().setUp()
Beispiel #3
0
class TestSendData(unittest.TestCase):
    def setUp(self) -> None:
        self.path = os.path.join(os.path.expanduser("~"), "key")
        DirManagement.create_dir(self.path)
        self.key = SaveApiKey()
        return super().setUp()

    def test_save(self):
        """
        return None
        """
        self.assertIsNone(self.key.save('K4nPEs7RhhCzcjdlvr3X=='))

    def test_readapikey(self):
        """
        return ...
        """
        self.key.save('K4nPEs7RhhCzcjdlvr3X==')
        self.assertIs(type(self.key.readapikey()), str)

    def test_writeapikey(self):
        """
        return None
        """
        self.assertIsNone(self.key.writeapikey('K4nPEs7RhhCzcjdlvr3X=='))

    def test_existapikey(self):
        """
        return boolean
        """
        self.assertTrue(self.key.exsitapikey())

    def test_removeapikey(self):
        """
        return None
        """
        self.assertIsNone(self.key.removeapikey())

    def tearDown(self) -> None:
        DirManagement.remove_dir(self.path)
        return super().tearDown()
Beispiel #4
0
def check_draft(path):
    if not os.path.exists(os.path.join(
            path, "ta", "draft.json")) and not SaveApiKey().exsitapikey():
        return False
    else:
        return True
Beispiel #5
0
def login(apikey):
    """Login"""
    SaveApiKey().save(apikey)
Beispiel #6
0
def check_api_key(path):
    if SaveApiKey().exsitapikey():
        return True
    else:
        return False
Beispiel #7
0
 def setUp(self) -> None:
     self.path = os.path.join(os.path.expanduser("~"), "key")
     DirManagement.create_dir(self.path)
     self.key = SaveApiKey()
     return super().setUp()
Beispiel #8
0
 def tearDown(self) -> None:
     SaveApiKey().removeapikey()
     DirManagement.remove_dir(self.path)
     return super().tearDown()