def test_http_get_specific_charger(self):
        from src import charger

        event = {
            'httpMethod': 'GET',
            'pathParameters': {
                'id': '632',
            },
        }

        dynamodb = boto3.resource('dynamodb', region_name='us-east-1')

        table = dynamodb.create_table(TableName=CHARGERS_TABLE,
                                      KeySchema=[
                                          {
                                              'AttributeName': 'id',
                                              'KeyType': 'HASH'
                                          },
                                      ],
                                      AttributeDefinitions=[
                                          {
                                              'AttributeName': 'id',
                                              'AttributeType': 'N'
                                          },
                                      ],
                                      ProvisionedThroughput={
                                          'ReadCapacityUnits': 5,
                                          'WriteCapacityUnits': 5
                                      })

        table = dynamodb.Table(CHARGERS_TABLE)
        table.put_item(Item=self.sc_test_data)

        response = charger.main(event, None)

        valid = {
            'statusCode':
            200,
            'body':
            ('{"id": 632.0, "locationId": "strasburgsupercharger", "name": '
             '"Strasburg, VA", "status": "OPEN", "address": {"street": '
             '"119 Hite Ln", "city": "Strasburg", "state": "VA", "zip": '
             '"22657", "countryId": 100.0, "country": "USA", "regionId": '
             '100.0, "region": "North America"}, "latitude": 39.0, '
             '"longitude": -78.0, "dateOpened": "2015-09-02", "stallCount"'
             ': 6.0, "counted": true, "elevationMeters": 204.0, '
             '"powerKilowatt": 0.0, "solarCanopy": false, "battery": '
             'false, "statusDays": 0.0, "urlDiscuss": true, "tips": [], '
             '"ratings": [{"theme": "FOOD", "rating": 0, "count": 0}, {'
             '"theme": "KIDS", "rating": 0, "count": 0}, {"theme": '
             '"RESTROOMS", "rating": 0, "count": 0}, {"theme": "SHOPPING", '
             '"rating": 0, "count": 0}, {"theme": "ATMOSPHERE", '
             '"rating": 0, "count": 0}]}'),
            'headers': {
                'Access-Control-Allow-Origin': '*',
                'Access-Control-Allow-Credentials': 'true',
            },
        }

        assert valid == response
    def test_http_get_invalid_charger(self):
        from src import charger

        event = {
            'httpMethod': 'GET',
            'pathParameters': {
                'id': '123',
            },
        }

        dynamodb = boto3.resource('dynamodb', region_name='us-east-1')

        table = dynamodb.create_table(TableName=CHARGERS_TABLE,
                                      KeySchema=[
                                          {
                                              'AttributeName': 'id',
                                              'KeyType': 'HASH'
                                          },
                                      ],
                                      AttributeDefinitions=[
                                          {
                                              'AttributeName': 'id',
                                              'AttributeType': 'N'
                                          },
                                      ],
                                      ProvisionedThroughput={
                                          'ReadCapacityUnits': 5,
                                          'WriteCapacityUnits': 5
                                      })

        table = dynamodb.Table(CHARGERS_TABLE)
        table.put_item(Item=self.sc_test_data)

        response = charger.main(event, None)
        print(response)
        valid = {
            'statusCode': 200,
            'body': 'Invalid Charger Id',
            'headers': {
                'Access-Control-Allow-Origin': '*',
                'Access-Control-Allow-Credentials': 'true',
            },
        }
        assert valid == response
 def test_http_post(self):
     from src import charger
     invalid_method = charger.main({'httpMethod': 'POST'}, None)
     assert invalid_method != self.status_404