Skip to content

Commit

Permalink
Merge branch 'release/1.54.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nshumoogum committed Feb 17, 2023
2 parents f45d4a5 + f28e647 commit bce3ae9
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Dockerfile.concourse
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM onsdigital/dp-concourse-tools-ubuntu
FROM onsdigital/dp-concourse-tools-ubuntu-20:ubuntu20.4-rc.1

WORKDIR /app/

Expand Down
16 changes: 13 additions & 3 deletions features/private_datasets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Feature: Private Dataset API
When I POST "/datasets/ageing-population-estimates"
"""
{
"title": "CID"
"state": "anything",
"title": "CID",
"type": "filterable"
}
"""
Then the HTTP status code should be "201"
Expand All @@ -19,7 +21,15 @@ Feature: Private Dataset API
"id": "ageing-population-estimates",
"state": "created",
"title": "CID",
"type": "filterable"
"type": "filterable",
"links": {
"editions": {
"href":"http://localhost:22000/datasets/ageing-population-estimates/editions"
},
"self": {
"href":"http://localhost:22000/datasets/ageing-population-estimates"
}
}
}
"""

Expand Down Expand Up @@ -120,7 +130,7 @@ Feature: Private Dataset API
"id": "population-estimates",
"related_content": [{
"description": "Related content description",
"href": "http://localhost:22000//datasets/123/relatedContent",
"href": "http://localhost:22000/datasets/123/relatedContent",
"title": "Related content"
}]
}
Expand Down
11 changes: 7 additions & 4 deletions features/steps/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ func (c *DatasetComponent) theDocumentInTheDatabaseForIdShouldBe(documentId stri

document := link.Next

assert.Equal(&c.ErrorFeature, expectedDataset.Title, document.Title)
assert.Equal(&c.ErrorFeature, expectedDataset.State, document.State)
// Remove the last updated value so to be able to compare the datasets
// otherwise the assertion would always fail as last updated would be "now"
document.LastUpdated = time.Time{}

assert.Equal(&c.ErrorFeature, expectedDataset, *document)

return c.ErrorFeature.StepError()
}
Expand Down Expand Up @@ -150,8 +153,8 @@ func (c *DatasetComponent) theseGenerateDownloadsEventsAreProduced(events *godog
return nil
}

//we are passing the string array as [xxxx,yyyy,zzz]
//this is required to support array being used in kafka messages
// we are passing the string array as [xxxx,yyyy,zzz]
// this is required to support array being used in kafka messages
func arrayParser(raw string) (interface{}, error) {
//remove the starting and trailing brackets
str := strings.Trim(raw, "[]")
Expand Down
4 changes: 0 additions & 4 deletions features/versions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@ Feature: Dataset API
},
"self": {
"href": "someurl"
},
"version": {
"id": "1",
"href": "someurl"
}
},
"edition": "2021",
Expand Down
12 changes: 9 additions & 3 deletions models/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
// Metadata represents information (metadata) relevant to a version
type Metadata struct {
Alerts *[]Alert `json:"alerts,omitempty"`
CanonicalTopic string `json:"canonical_topic,omitempty"`
Contacts []ContactDetails `json:"contacts,omitempty"`
Description string `json:"description,omitempty"`
Dimensions []Dimension `json:"dimensions,omitempty"`
Expand All @@ -30,6 +31,7 @@ type Metadata struct {
Temporal *[]TemporalFrequency `json:"temporal,omitempty"`
Theme string `json:"theme,omitempty"`
Title string `json:"title,omitempty"`
Subtopics []string `json:"subtopics,omitempty"`
UnitOfMeasure string `json:"unit_of_measure,omitempty"`
URI string `json:"uri,omitempty"`
UsageNotes *[]UsageNote `json:"usage_notes,omitempty"`
Expand Down Expand Up @@ -58,6 +60,7 @@ type MetadataLinks struct {
func CreateMetaDataDoc(datasetDoc *Dataset, versionDoc *Version, urlBuilder *url.Builder) *Metadata {
metaDataDoc := &Metadata{
Alerts: versionDoc.Alerts,
CanonicalTopic: datasetDoc.CanonicalTopic,
Contacts: datasetDoc.Contacts,
Description: datasetDoc.Description,
Dimensions: versionDoc.Dimensions,
Expand All @@ -75,6 +78,7 @@ func CreateMetaDataDoc(datasetDoc *Dataset, versionDoc *Version, urlBuilder *url
RelatedDatasets: datasetDoc.RelatedDatasets,
ReleaseDate: versionDoc.ReleaseDate,
ReleaseFrequency: datasetDoc.ReleaseFrequency,
Subtopics: datasetDoc.Subtopics,
Temporal: versionDoc.Temporal,
Theme: datasetDoc.Theme,
Title: datasetDoc.Title,
Expand Down Expand Up @@ -136,19 +140,21 @@ func CreateMetaDataDoc(datasetDoc *Dataset, versionDoc *Version, urlBuilder *url
func CreateCantabularMetaDataDoc(d *Dataset, v *Version, urlBuilder *url.Builder) *Metadata {
m := &Metadata{
CSVHeader: v.Headers,
CanonicalTopic: d.CanonicalTopic,
Contacts: d.Contacts,
DatasetLinks: d.Links,
Description: d.Description,
Dimensions: v.Dimensions,
Downloads: v.Downloads,
Keywords: d.Keywords,
RelatedContent: d.RelatedContent,
ReleaseDate: v.ReleaseDate,
Subtopics: d.Subtopics,
Title: d.Title,
UnitOfMeasure: d.UnitOfMeasure,
Contacts: d.Contacts,
URI: d.URI,
QMI: d.QMI,
Version: v.Version,
DatasetLinks: d.Links,
RelatedContent: d.RelatedContent,
}

m.Distribution = getDistribution(m.Downloads)
Expand Down
10 changes: 6 additions & 4 deletions models/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ func TestCreateCantabularMetadataDoc(t *testing.T) {

Convey("Successfully create metadata document with all relavant cantabular fields", t, func() {
inputDatasetDoc := &Dataset{
Description: "census",
Keywords: []string{"test", "test2"},
Title: "CensusEthnicity",
UnitOfMeasure: "Pounds Sterling",
CanonicalTopic: "1234",
Description: "census",
Keywords: []string{"test", "test2"},
Subtopics: []string{"5678", "9012"},
Title: "CensusEthnicity",
UnitOfMeasure: "Pounds Sterling",
}

inputVersionDoc := &publishedVersion
Expand Down
42 changes: 23 additions & 19 deletions models/test_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,15 +257,16 @@ var badInputData = struct {

func expectedMetadataDoc() Metadata {
return Metadata{
Alerts: &[]Alert{alert},
Contacts: []ContactDetails{contacts},
Description: "census",
Dimensions: []Dimension{dimension},
Distribution: []string{"json", "csv", "xls"},
Downloads: &downloads,
Keywords: []string{"test", "test2"},
LatestChanges: &[]LatestChange{latestChange},
License: "Office of National Statistics license",
Alerts: &[]Alert{alert},
CanonicalTopic: "canonicalTopicID",
Contacts: []ContactDetails{contacts},
Description: "census",
Dimensions: []Dimension{dimension},
Distribution: []string{"json", "csv", "xls"},
Downloads: &downloads,
Keywords: []string{"test", "test2"},
LatestChanges: &[]LatestChange{latestChange},
License: "Office of National Statistics license",
Links: &MetadataLinks{
AccessRights: &LinkObject{
HRef: "http://ons.gov.uk/accessrights",
Expand All @@ -286,6 +287,7 @@ func expectedMetadataDoc() Metadata {
RelatedDatasets: []GeneralDetails{relatedDatasets},
ReleaseDate: "2017-10-12",
ReleaseFrequency: "yearly",
Subtopics: []string{"subtopicID"},
Temporal: &[]TemporalFrequency{temporal},
Theme: "population",
Title: "CensusEthnicity",
Expand All @@ -296,15 +298,17 @@ func expectedMetadataDoc() Metadata {

func expectedCantabularMetadataDoc() Metadata {
return Metadata{
Description: "census",
Dimensions: []Dimension{dimension},
CSVHeader: []string{"cantabular_table", "age"},
Distribution: []string{"json", "csv", "csvw", "xls"},
Downloads: &cantabularDownloads,
Keywords: []string{"test", "test2"},
ReleaseDate: "2017-10-12",
Title: "CensusEthnicity",
UnitOfMeasure: "Pounds Sterling",
Version: 1,
CSVHeader: []string{"cantabular_table", "age"},
CanonicalTopic: "1234",
Description: "census",
Dimensions: []Dimension{dimension},
Distribution: []string{"json", "csv", "csvw", "xls"},
Downloads: &cantabularDownloads,
Keywords: []string{"test", "test2"},
ReleaseDate: "2017-10-12",
Subtopics: []string{"5678", "9012"},
Title: "CensusEthnicity",
UnitOfMeasure: "Pounds Sterling",
Version: 1,
}
}
8 changes: 8 additions & 0 deletions swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,9 @@ definitions:
type: array
items:
$ref: '#/definitions/Alert'
canonical_topic:
description: "The canonical topic id for this dataset. This indicates which topic this dataset belongs to within the website taxonomy."
type: string
contacts:
description: "A list containing contact details of staticians for a dataset"
type: array
Expand Down Expand Up @@ -1889,6 +1892,11 @@ definitions:
release_frequency:
description: "The release frequency of a dataset"
type: string
subtopics:
description: "A list of subtopic ids that the dataset relates to within the website taxonomy."
type: array
items:
type: "string"
temporal:
$ref: '#/definitions/Temporal'
theme:
Expand Down

0 comments on commit bce3ae9

Please sign in to comment.