Skip to content

Commit

Permalink
Merge pull request #29 from smartcitiesdata/schema_atoms
Browse files Browse the repository at this point in the history
Changed schema generated by TestDataGenerator to have atoms as keys
  • Loading branch information
dunson062786 authored Sep 10, 2019
2 parents b65a7f0 + b51165f commit bd20b19
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ For more information about the `SmartCity.TestDataGenerator`, please see [https:
```elixir
def deps do
[
{:smart_city_test, "~> 0.5.0"}
{:smart_city_test, "~> 0.5.1"}
]
end
```

## License

SmartCity is released under the Apache 2.0 license - see the license at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)

2 changes: 1 addition & 1 deletion lib/smart_city/test_data_generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule SmartCity.TestDataGenerator do
business: %{
dataTitle: title,
description: Faker.Lorem.Shakespeare.hamlet(),
modifiedDate: Faker.Date.backward(360),
modifiedDate: Faker.Date.backward(360) |> Date.to_iso8601(),
orgTitle: org,
contactName: Faker.Name.name(),
contactEmail: Faker.Internet.email(),
Expand Down
2 changes: 1 addition & 1 deletion lib/smart_city/test_data_generator/payload.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule SmartCity.TestDataGenerator.Payload do
Enum.reduce(columns, %{}, &generate_value/2)
end

defp generate_value(%{"name" => column, "type" => type}, acc) do
defp generate_value(%{name: column, type: type}, acc) do
Map.put(acc, column, generate_from_type({column, type}))
end

Expand Down
56 changes: 28 additions & 28 deletions lib/smart_city/test_data_generator/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ defmodule SmartCity.TestDataGenerator.Schema do
%{
"schema" => [
%{
"name" => "id",
"type" => "int"
name: "id",
type: "int"
},
%{
"name" => "name",
"type" => "string"
name: "name",
type: "string"
}
]
}}
Expand All @@ -28,20 +28,20 @@ defmodule SmartCity.TestDataGenerator.Schema do
%{
"schema" => [
%{
"name" => "big",
"type" => "string"
name: "big",
type: "string"
},
%{
"name" => "bigbig",
"type" => "int"
name: "bigbig",
type: "int"
},
%{
"name" => "data",
"type" => "float"
name: "data",
type: "float"
},
%{
"name" => "bigger_data",
"type" => "date"
name: "bigger_data",
type: "date"
}
]
}}
Expand All @@ -52,16 +52,16 @@ defmodule SmartCity.TestDataGenerator.Schema do
%{
"schema" => [
%{
"name" => "go",
"type" => "int"
name: "go",
type: "int"
},
%{
"name" => "fund",
"type" => "string"
name: "fund",
type: "string"
},
%{
"name" => "yourself",
"type" => "string"
name: "yourself",
type: "string"
}
]
}}
Expand All @@ -72,24 +72,24 @@ defmodule SmartCity.TestDataGenerator.Schema do
%{
"schema" => [
%{
"name" => "my_int",
"type" => "int"
name: "my_int",
type: "int"
},
%{
"name" => "my_string",
"type" => "string"
name: "my_string",
type: "string"
},
%{
"name" => "my_date",
"type" => "date"
name: "my_date",
type: "date"
},
%{
"name" => "my_float",
"type" => "float"
name: "my_float",
type: "float"
},
%{
"name" => "my_boolean",
"type" => "boolean"
name: "my_boolean",
type: "boolean"
}
]
}}
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule SmartCityTest.MixProject do
def project do
[
app: :smart_city_test,
version: "0.5.0",
version: "0.5.1",
elixir: "~> 1.8",
start_permanent: Mix.env() == :prod,
description: description(),
Expand Down
13 changes: 7 additions & 6 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
%{
"brod": {:hex, :brod, "3.8.1", "74426e2d27989cd7f973599bc209c899dca8588068d27a2a37ca1b4bf8823c2a", [:make, :rebar, :rebar3], [{:kafka_protocol, "2.2.9", [hex: :kafka_protocol, repo: "hexpm", optional: false]}, {:supervisor3, "1.1.8", [hex: :supervisor3, repo: "hexpm", optional: false]}], "hexpm"},
"brook": {:hex, :brook, "0.1.1", "d855e06824f7cb34a8ee4c0d260cf86b67a728e3a5a6c32d02a70c9fd042ce30", [:mix], [{:elsa, "~> 0.7.1", [hex: :elsa, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:redix, "~> 0.10.2", [hex: :redix, repo: "hexpm", optional: false]}], "hexpm"},
"brook_serializer": {:hex, :brook_serializer, "1.0.0", "b1306e8d07669df94664267646f9a8c01746b5bee73b1ffd832f51ad35067b6a", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"},
"crc32cer": {:hex, :crc32cer, "0.1.3", "8984906c4b4fae6aa292c48f286a1c83b19ad44bd102287acb94d696015967ce", [:make, :rebar, :rebar3], [], "hexpm"},
"credo": {:hex, :credo, "1.1.3", "bf31887b8914a4b7e1810ae2b5aab7c657698abbf4cca6a2335a094d57995168", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"credo": {:hex, :credo, "1.1.4", "c2f3b73c895d81d859cec7fcee7ffdb972c595fd8e85ab6f8c2adbf01cf7c29c", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"},
"dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.3.3", "5e8be428fcef362692b6dbd7dc55bdc7023da26d995cb3fb19aa4bd682bfd3f9", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.4.0", "397e750b879df18198afc66505ca87ecf6a96645545585899f6185178433cc09", [:mix], [], "hexpm"},
"elsa": {:hex, :elsa, "0.7.1", "3615e3aa3c2d7b9aa165f7638fee01e8208f0c6785f9cc43f57f3f36218d7073", [:mix], [{:brod, "~> 3.7", [hex: :brod, repo: "hexpm", optional: false]}], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.21.1", "5ac36660846967cd869255f4426467a11672fec3d8db602c429425ce5b613b90", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.21.2", "caca5bc28ed7b3bdc0b662f8afe2bee1eedb5c3cf7b322feeeb7c6ebbde089d6", [:mix], [{:earmark, "~> 1.3.3 or ~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"faker": {:hex, :faker, "0.12.0", "796cbac868c86c2df6f273ea4cdf2e271860863820e479e04a374b7ee6c376b6", [:mix], [], "hexpm"},
"husky": {:hex, :husky, "1.0.3", "960fd2c74214ba3640693ff89fff39abf0a271c4ff42659e6eb8ffbc26f33927", [:mix], [{:poison, ">= 1.2.1", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"},
"jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
"kafka_protocol": {:hex, :kafka_protocol, "2.2.9", "fbec2ddb607a0cb05b832a93dcfdd4dbae6bd3b838c9aace93f6871bbb91f81f", [:rebar, :rebar3], [{:crc32cer, "0.1.3", [hex: :crc32cer, repo: "hexpm", optional: false]}, {:snappyer, "1.2.4", [hex: :snappyer, repo: "hexpm", optional: false]}], "hexpm"},
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.1", "c90796ecee0289dbb5ad16d3ad06f957b0cd1199769641c961cfe0b97db190e0", [:mix], [], "hexpm"},
"patiently": {:hex, :patiently, "0.2.0", "67eb139591e10c4b363ae0198e832552f191c58894731efd3bf124ec4722267a", [:mix], [], "hexpm"},
"redix": {:hex, :redix, "0.10.2", "a9eabf47898aa878650df36194aeb63966d74f5bd69d9caa37babb32dbb93c5d", [:mix], [{:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
"smart_city": {:hex, :smart_city, "2.6.1", "99358cea07ac0b319a2d86d1359f3252b494256e51579cacefcb4ea5863cb6cd", [:mix], [{:brook, "~> 0.1.1", [hex: :brook, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 1.3", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},
"smart_city_data": {:hex, :smart_city_data, "3.0.1", "2754c29df0aca41f6494d47435264de28232c8d2b7e7f57bd0903c6f7915dd34", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:smart_city, "~> 2.6.1", [hex: :smart_city, repo: "hexpm", optional: false]}], "hexpm"},
"smart_city": {:hex, :smart_city, "2.8.0", "e88cf8a2bb6270705a3fcd9537f38d2ba1c6a7479123c491e68f354e89b7df95", [:mix], [{:brook_serializer, "~> 1.0", [hex: :brook_serializer, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 1.3", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"},
"smart_city_data": {:hex, :smart_city_data, "3.0.2", "3ab715fe9ee40de326dd5b1bc4518c04bed7f3cd3577cbb72f5f7866a95c4443", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:smart_city, "~> 2.7", [hex: :smart_city, repo: "hexpm", optional: false]}], "hexpm"},
"smart_city_registry": {:hex, :smart_city_registry, "4.0.0", "e3b86865b9c9340c15cfc93d7055249d1de85f53398ec3800d3d3b17b238f920", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:redix, "~> 0.9", [hex: :redix, repo: "hexpm", optional: false]}, {:smart_city, "~> 2.1", [hex: :smart_city, repo: "hexpm", optional: false]}], "hexpm"},
"snappyer": {:hex, :snappyer, "1.2.4", "6d739c534cd2339633127a2b40279be71f149e5842c5363a4d88e66efb7c1fec", [:make, :rebar, :rebar3], [], "hexpm"},
"supervisor3": {:hex, :supervisor3, "1.1.8", "5cf95c95342b589ec8d74689eea0646c0a3eb92820241e0c2d0ca4c104df92bc", [:make, :rebar, :rebar3], [], "hexpm"},
Expand Down
10 changes: 5 additions & 5 deletions test/smart_city/test_data_generator/payload_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ defmodule SmartCity.TestDataGenerator.PayloadTest do

test "get_schema returns schema as list of maps" do
expected = [
%{"name" => "my_int", "type" => "int"},
%{"name" => "my_string", "type" => "string"},
%{"name" => "my_date", "type" => "date"},
%{"name" => "my_float", "type" => "float"},
%{"name" => "my_boolean", "type" => "boolean"}
%{name: "my_int", type: "int"},
%{name: "my_string", type: "string"},
%{name: "my_date", type: "date"},
%{name: "my_float", type: "float"},
%{name: "my_boolean", type: "boolean"}
]

assert Payload.get_schema(:test) == expected
Expand Down

0 comments on commit bd20b19

Please sign in to comment.