Esempio n. 1
0
    def setUp(self):
        self.headers = {'Content-Type': 'application/json', 'App-Version': '*'}

        register_data = register_david_janzen(self.base_url, self.headers)
        self.assertTrue('id' in register_data)
        self.assertTrue(register_data['id'] > 0)

        login_data = login_david_janzen(self.base_url, self.headers)
        self.assertIsNotNone(login_data['userId'])
        self.assertIsNotNone(login_data['token'])
        self.headers['Authorization'] = 'token ' + login_data['token']

        league_data = create_league(self.base_url, self.headers)
        self.assertIsNotNone(league_data['id'])
        self.assertIsNotNone(league_data['inviteCode'])
        self.assertIsNotNone(league_data['startPos'])

        portfolio_data = create_portfolio(self.base_url, self.headers,
                                          league_data['inviteCode'])
        self.assertTrue('id' in portfolio_data)
        self.assertTrue(portfolio_data['id'] > 0)
        self.assertTrue('buyPower' in portfolio_data)
        self.assertEquals(portfolio_data['buyPower'], 5000)

        self.portfolio_id = portfolio_data['id']
        self.url = self.base_url + '/watchlists'
Esempio n. 2
0
    def setUp(self):
        self.headers = {'Content-Type': 'application/json', 'App-Version': '*'}

        register_data = register_david_janzen(self.base_url, self.headers)
        self.assertTrue('id' in register_data)
        self.assertTrue(register_data['id'] > 0)

        login_data = login_david_janzen(self.base_url, self.headers)
        self.assertIsNotNone(login_data['userId'])
        self.assertIsNotNone(login_data['token'])
        self.headers['Authorization'] = 'token ' + login_data['token']

        # Create multiple leagues
        # Have to do it through the database because it breaks api rules for creating new leagues
        DATE_FORMAT = "%m-%d-%Y"

        self.cursor.execute(
            "Insert INTO League(name, start, end, startPos, inviteCode, ownerId) "
            + "VALUES (%s, %s, %s, %s, %s, %s)", [
                'testLeague1',
                datetime.strptime('01-15-2025', DATE_FORMAT),
                datetime.strptime('01-15-2026', DATE_FORMAT), 2500, "abc", 0
            ])

        self.cursor.execute(
            "Insert INTO League(name, start, end, startPos, inviteCode, ownerId) "
            + "VALUES (%s, %s, %s, %s, %s, %s)", [
                'testLeague2',
                datetime.strptime('07-07-2019', DATE_FORMAT),
                datetime.strptime('07-07-2029', DATE_FORMAT), 800, "def", 0
            ])

        self.cursor.execute(
            "Insert INTO League(name, start, end, startPos, inviteCode, ownerId) "
            + "VALUES (%s, %s, %s, %s, %s, %s)", [
                'testLeague3',
                datetime.strptime('11-20-2018', DATE_FORMAT),
                datetime.strptime('12-30-2018', DATE_FORMAT), 43000, "ghi", 0
            ])

        self.cursor.execute(
            "Insert INTO League(name, start, end, startPos, inviteCode, ownerId) "
            + "VALUES (%s, %s, %s, %s, %s, %s)", [
                'testLeague4',
                datetime.strptime('03-15-2024', DATE_FORMAT),
                datetime.strptime('02-15-2025', DATE_FORMAT), 10000, "jkl", 0
            ])

        self.url = self.base_url + '/leagues'
Esempio n. 3
0
    def setUp(self):
        self.headers = {'Content-Type': 'application/json', 'App-Version': '*'}

        register_data = register_david_janzen(self.base_url, self.headers)
        self.assertTrue('id' in register_data)
        self.assertTrue(register_data['id'] > 0)

        login_data = login_david_janzen(self.base_url, self.headers)
        self.assertIsNotNone(login_data['userId'])
        self.assertIsNotNone(login_data['token'])
        self.headers['Authorization'] = 'token ' + login_data['token']

        league_data = create_league(self.base_url, self.headers)
        self.assertIsNotNone(league_data['id'])
        self.assertIsNotNone(league_data['inviteCode'])
        self.assertIsNotNone(league_data['startPos'])

        portfolio_data = create_portfolio(self.base_url, self.headers,
                                          league_data['inviteCode'])
        self.assertTrue('id' in portfolio_data)
        self.assertTrue(portfolio_data['id'] > 0)
        self.assertTrue('buyPower' in portfolio_data)
        self.assertEquals(portfolio_data['buyPower'], 5000)

        self.portfolioId = portfolio_data['id']
        self.invite_code = league_data['inviteCode']
        self.url = self.base_url + '/portfolios'

        # Manually add leagues that aren't in the acceptable date range
        self.cursor.execute(
            'INSERT INTO League(name, start, end, startPos, inviteCode, ' +
            'ownerId) ' +
            'VALUES("plannedleague", "2100-01-01", "2110-01-01",' +
            ' 1000, "ic1", %s)', [register_data["id"]])
        self.planned_league_id = self.cursor.lastrowid

        self.cursor.execute(
            'INSERT INTO League(name, start, end, startPos, inviteCode, ' +
            'ownerId) ' + 'VALUES("endedleague", "2020-02-22", "2020-02-27",' +
            ' 1000, "ic2", %s)', [register_data["id"]])
        self.ended_league_id = self.cursor.lastrowid

        self.cursor.execute(
            'INSERT INTO League(name, start, end, startPos, inviteCode, ' +
            'ownerId) ' +
            'VALUES("activeleague", "1900-01-01", "2100-01-01",' +
            ' 1000, "ic3", %s)', [register_data["id"]])
        self.active_league_id = self.cursor.lastrowid
Esempio n. 4
0
   def setUp(self):
      self.headers = {
            'Content-Type': 'application/json',
            'App-Version': '*'
        }

      register_data = register_david_janzen(self.base_url, self.headers)
      self.assertTrue('id' in register_data)
      self.assertTrue(register_data['id'] > 0)

      login_data = login_david_janzen(self.base_url, self.headers)
      self.assertIsNotNone(login_data['userId'])
      self.assertIsNotNone(login_data['token'])

      self.user_id = login_data['userId']
      self.token = login_data['token']
      self.headers['Authorization'] = 'token ' + self.token
      self.url = self.base_url + '/stocks'
Esempio n. 5
0
    def setUp(self):
        self.headers = {'Content-Type': 'application/json', 'App-Version': '*'}

        register_data = register_david_janzen(self.base_url, self.headers)
        self.assertTrue('id' in register_data)
        self.assertTrue(register_data['id'] > 0)

        login_data = login_david_janzen(self.base_url, self.headers)
        self.assertIsNotNone(login_data['userId'])
        self.assertIsNotNone(login_data['token'])
        self.headers['Authorization'] = 'token ' + login_data['token']

        league_data = create_league(self.base_url, self.headers)
        self.assertIsNotNone(league_data['id'])
        self.assertIsNotNone(league_data['inviteCode'])
        self.assertIsNotNone(league_data['startPos'])

        portfolio_data = create_portfolio(self.base_url, self.headers,
                                          league_data['inviteCode'])
        self.assertTrue('id' in portfolio_data)
        self.assertTrue(portfolio_data['id'] > 0)
        self.assertTrue('buyPower' in portfolio_data)
        self.assertEquals(portfolio_data['buyPower'], 5000)

        self.portfolioId = portfolio_data['id']
        self.url = self.base_url + '/portfolios'
        self.invite_code = league_data['inviteCode']
        self.user_id = login_data['userId']

        # Adding PortfolioHistory stuff manually
        self.cursor.execute(
            'INSERT INTO PortfolioHistory(portfolioId, datetime, value) VALUES(%s, DATE_SUB(CURDATE(), INTERVAL 2 DAY), %s)',
            (portfolio_data['id'], 2950))

        self.cursor.execute(
            'INSERT INTO PortfolioHistory(portfolioId, datetime, value) VALUES(%s, DATE_SUB(CURDATE(), INTERVAL 1 DAY), %s)',
            (portfolio_data['id'], 3000))

        self.cursor.execute(
            'INSERT INTO PortfolioHistory(portfolioId, datetime, value) VALUES(%s, NOW(), %s)',
            (portfolio_data['id'], 3010))
    def setUp(self):
        self.headers = {'Content-Type': 'application/json', 'App-Version': '*'}

        register_data = register_david_janzen(self.base_url, self.headers)
        self.assertTrue('id' in register_data)
        self.assertTrue(register_data['id'] > 0)

        login_data = login_david_janzen(self.base_url, self.headers)
        self.assertIsNotNone(login_data['userId'])
        self.assertIsNotNone(login_data['token'])
        self.headers['Authorization'] = 'token ' + login_data['token']

        league_data = create_league(self.base_url, self.headers)
        self.assertIsNotNone(league_data['id'])
        self.assertIsNotNone(league_data['inviteCode'])
        self.assertIsNotNone(league_data['startPos'])

        self.user_id = login_data['userId']

        self.league_id = league_data['id']
        self.invite_code = league_data['inviteCode']
        self.league_start_pos = league_data['startPos']

        self.url = self.base_url + '/portfolios'