Beispiel #1
0
    def test_get_deck_no_valid_id(self):

        handler = DeckHandler(self.new_dir)
        user_id = "TestUser"
        deck_id = "xyz"
        deck = handler.get_deck(user_id, deck_id)
        self.assertEqual({}, deck)
Beispiel #2
0
    def test_delete_deck_nonExistingDeck(self):

        handler = DeckHandler(self.new_dir)
        self.assertEqual(len(self.test_files_dict), len(os.listdir(self.new_dir)))
        userId = ""
        deckId = 'xyz' # xyz is not the id
        response = handler.delete_deck(userId, deckId)
        self.assertEqual(len(self.test_files_dict), len(os.listdir(self.new_dir)))
        self.assertFalse(response)
Beispiel #3
0
    def test_delete_deck(self):

        handler = DeckHandler(self.new_dir)
        self.assertEqual(len(self.test_files_dict), len(os.listdir(self.new_dir)))
        userId = "Tester"
        deckId = 'valide'
        response = handler.delete_deck(userId, deckId)
        self.assertEqual(len(self.test_files_dict)-1, len(os.listdir(self.new_dir)))
        self.assertTrue(response)
Beispiel #4
0
 def test_list_decks(self):
     """ test for method: get_decks"""
     
     handler = DeckHandler(self.new_dir)
     user_list = ["Leo"]
     for user in user_list:
         TestUtils.blockPrint()
         dictList = handler.list_decks(user)
         TestUtils.enablePrint()
         self.assertEqual(1, len(dictList))
Beispiel #5
0
    def test_get_deck(self):

        handler = DeckHandler(self.new_dir)
        user_id = "TestUser"
        deck_id = "valide"
        deck = handler.get_deck(user_id, deck_id)
        testDict = self.testdict
        testDict.update({'creatorname': deck['creatorname']})
        testDict.update({'id': deck['id']})
        self.assertIsNotNone(deck)
        self.assertEqual(self.testdict, deck)
Beispiel #6
0
    def test_create_deck(self):
        
        handler = DeckHandler(self.new_dir)
        deck = handler.create_deck('TestUser', self.testdict)
        testDict = self.testdict
        testDict.update({'creatorname': "TestUser"})
        testDict.update({'id': deck['id']})

        self.assertIsNotNone(deck)
        with open(os.path.join(self.new_dir,  deck['id'])) as f:
            deckDict = json.load(f)
            self.assertDictEqual(self.testdict, deckDict)
Beispiel #7
0
#!/usr/bin/env python3
import connexion
import logging
from client.main.deckhandler import DeckHandler

deck_handler = DeckHandler()


def list_decks():
    user_id = connexion.request.headers["userId"]
    return deck_handler.list_decks(user_id)


def create_deck(deck):
    user_id = connexion.request.headers["userId"]
    return deck_handler.create_deck(user_id, deck)


def get_deck(deckId):
    user_id = connexion.request.headers["userId"]
    return deck_handler.get_deck(user_id, deckId)


def delete_deck(deckId):
    user_id = connexion.request.headers["userId"]
    if deck_handler.delete_deck(user_id, deckId):
        return 204
    else:
        return 404